<%@ page language="java" import="java.util.*,cn.ac.cintcm.dataconverge.util.Constants,com.hs.core.utils.*" pageEncoding="UTF-8"%>
<%@ page import ="cn.ac.cintcm.dataconverge.researchsubject.domain.*,com.hs.core.page.PageUtil,com.hs.core.utils.StringUtilTool" %> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 
String imagePath = path + "/index/";
List orgList = (List)request.getAttribute("orgList");
List resultOrg = (List)request.getAttribute("resultOrg");
String achId = (String)request.getAttribute("achId");

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title><%=Constants.APP_TITLE %></title>  
	<script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
	<script language="javascript" src="<%=path %>/index/Scripts/script.js"></script>
	<script language="javascript" src="<%=path %>/js/common.js"></script>
	<link href="<%=path %>/index/Themes/com/style.css" type="text/css" rel="stylesheet"></link>
	<script src='<%=basePath%>dwr/engine.js'></script>
     <script src='<%=basePath%>dwr/util.js'></script> 
     <script src='<%=basePath%>dwr/interface/subject.js'></script> 
	
	<script type="text/javascript">
	  
     function changeTop(){ 
         var obj = parent.frames("bannerFrame"); 
         obj.location.href="<%=path%>/achieve.htm?action=top&modId=6&achId=<%=achId %>";
    }
     function orgSearch(){
      	 var orgName = document.getElementById("orgName").value;  
      	 dwr.util.removeAllOptions("org");
         subject.getOrgListInfoResult(orgName,CallBackSearchOrg);  
      }
      function CallBackSearchOrg(dataStr){  
       if(''!= dataStr){  
          dwr.util.addOptions("org", eval(dataStr),'id','name');  
       }  
     }
     function addOrg(){
        var orgId = dwr.util.getValue("org");
        if(isNull(orgId)){
           alert("请选择要添加的课题完成单位");
           document.getElementById("org").focus();
           return;
        }
        subject.addResultOrg(<%=achId%>,orgId,addCallBack);
        
     }
     function addCallBack(message){
        alert(message);
        document.location.replace(window.location.href);
     }
     function delOrg(id){
        if(confirm("确认要删除该成果完成单位吗？")){
           subject.delResultOrg(id,delCallBack);
        }
     
     }
     function delCallBack(message){
        alert(message);
        document.location.replace(window.location.href);
     }
	</script>
</head>
<body  class="rtm_body"  cellspacing="0" cellpadding="0"  >
    <table cellpadding="0" cellspacing="0" border="0" valign="top" width="100%">
        <tr>
            <td>
                <div class="content">
                    <table width="*" cellpadding="0" cellspacing="1" class="dg_borderstyle" id="Table4">
                        <tr>
                            <td class="dg_headerstyle" width="5%">
                               	序号</td>
                            <td class="dg_headerstyle" width="35%">
                                 单位名称</td>  
                            <td class="dg_headerstyle">
                                删除</td> 
                        </tr>
                        <%   
                        
                        if(resultOrg != null && resultOrg.size() > 0){
	                         for(int i=0;i<resultOrg.size();i++){
	                        	 Map m = (Map)resultOrg.get(i);
	                        	 
	                        %>
	                        <tr class="dg_alternatingitemstyle">
	                            <td align="center">
	                                <%=i+1 %></td> 
	                            <td>
	                                <%=StringUtilTool.setObjNULLStr(m.get("NAME")) %>
	                            </td> 
	                            <td align="center">
	                                <img src="<%=imagePath %>Themes/com/68design.net_registration1_(delete)_16x16.gif" onclick="javascript:delOrg('<%=m.get("ID") %>');"
	                                    alt="删除" />
	                            </td> 
	                        </tr> 
                        <%}}else{ %>
                          <tr class="dg_alternatingitemstyle"> 
                            <td align="center" colspan=5>
                                <font color="red">没有找到记录</font>
                            </td> 
                        </tr> 
                        
                        <%} %>
                    </table>  
                </div>
            </td>
        </tr>
    </table>
 
 <table cellpadding="0" cellspacing="0" width="100%" height="100%" id="Table8">
 <FORM name="form0"> 
        <tr>
            <td valign="top" height="100%">
                <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="Table11">
                    <tr>
                        <td valign="top" >
                            <!------------------ 标题栏 ------------------>
                            <!--- 标题 ---->
                            <table class="idt_tle_mg" cellspacing="0" cellpadding="0" width="100%">
                                <tr>
                                    <td class="idt_tle_i">
                                        <img id="imgForm6" src="<%=basePath%>index/Themes/com/idt_tle_o.gif"></td>
                                    <td class="idt_tle_f1">
                                        添加成果完成单位</td>
                                </tr>
                            </table>
                            <!--- 内容 --->
                            <div id="tdForm">
                                <table border="0" cellpadding="0" cellspacing="1" width="100%" class="idt_fim_mg">
                                    <tr>
                                        <td class="fim_l" align="center" width="15%">
                                           单位查询</td>
                                        <td class="fim_r" colspan="3" nowrap>
                                        <input name="outOrgName" onpropertychange="orgSearch();" id="orgName" class="com_textbox" type="text"  style="width:50%"/>
                                         
                                         <font color=red><b>提示：请先输入要添加的单位名称的全称或者简称进行查询!</b></font> 
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="fim_l" width="15%" align="center">
                                           可选单位</td>
                                        <td class="fim_r"  colspan=3 width="70%">
                                        <select name="org"   size="13" style="width:50%">
                                         <option value=""></option> 
				    					 <%
				    					  if(orgList != null && orgList.size()>0){
				    						  for(int i = 0;i<orgList.size();i++){
				    							  Map mm = (Map)orgList.get(i);
				    							  out.print("<option value=");
				    							  out.print(mm.get("ID"));
				    							  out.print(">");
				    							  out.print(mm.get("NAME"));
				    							  out.print("</option>");
				    						  }
				    					  }
				    					 
				    					 %>
				    			       </select>
				    			         <font color=red>提示:请在右侧列表中选择要添加的单位</font> 
                                        </td>
                                         
                                    </tr> 
                                </table>
                                <table cellspacing="0" cellpadding="0" width="100%" class="idt_bottom_mg" border="0">
                                    <tr>
                                        <td align="center">
                                         <input type="button" value="添加成果完成单位"     onclick="addOrg();">
                                            <!-- <input  class="com_btn2" id="Button1" name="save" type="button"  value="上一步">
                                            &nbsp; &nbsp;
                                             <input  class="com_btn2" id="Button1" name="save" type="button" value="下一步">
                                             -->
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            </form>
                </table>
</body>
</html>
<script>
changeTop(); 
</script>